cmake_minimum_required(VERSION 3.20)

set(CMAKE_CXX_STANDARD 17)

# 项目名称
project(SGFEM LANGUAGES CXX)


# 获取此项目源文件
glob_recurse_all_cpp_files("${CMAKE_CURRENT_SOURCE_DIR}" ALL_CPP_FILES)
add_executable(${PROJECT_NAME} ${ALL_CPP_FILES} ${CMAKE_SOURCE_DIR}/Resource/version.rc)


# 设置头文件查找目录
target_include_directories(
  ${PROJECT_NAME}
  PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../
  PRIVATE ${CMAKE_INSTALL_PREFIX}/include/)

# 链接库
target_link_directories(${PROJECT_NAME} PRIVATE ${CMAKE_INSTALL_PREFIX}/lib)
target_link_libraries(
  ${PROJECT_NAME}
  PRIVATE Logging
  PRIVATE Configuration
  PRIVATE Exception
  PRIVATE Stacktrace
  PRIVATE Algebra
  PRIVATE DataStructure
  PRIVATE DBManager
  PRIVATE Import
  PRIVATE Framework
  PRIVATE ElementCalculator
  PRIVATE PublicElement
  PRIVATE ADVEleCalculator
  PRIVATE Constraint
  PRIVATE SolverTask
  PRIVATE Export)

if(SG_LICENSE_CHECK)
  add_definitions(-DSG_LICENSE_CHECK)
  target_link_libraries(${PROJECT_NAME} PRIVATE Security)
endif()

if(MINGW AND SG_USE_RANDOM_TOOLS)
  target_link_libraries(${PROJECT_NAME} PRIVATE RandomTools)
  target_compile_definitions(${PROJECT_NAME} PRIVATE SG_USE_RANDOM_TOOLS)
endif()

# 导入第三方库
import_eigen3()

# 安装设置
install(
  TARGETS ${PROJECT_NAME}
  ARCHIVE DESTINATION lib
  RUNTIME DESTINATION bin)

